package springapp.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import springapp.service.ProductManager;

public class InventoryController
	implements Controller
{
	
	protected final Log logger = LogFactory.getLog(getClass());
    private ProductManager productManager;

	
	public ModelAndView handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) 
		throws Exception 
	{
		
        Map<String, Object> myModel = new HashMap<String, Object>();        
        	myModel.put("products", this.productManager.getProducts());

        return new ModelAndView("hello", "model", myModel);
        
	}
	
	public void setProductManager(ProductManager productManager) 
	{
        this.productManager = productManager;
    }

	
}
